<template>
	<div style="display: flex;flex-direction: column;" class="otherPage productsAndServices saleAnnouncements">
		<Header :selected="5"></Header>
		<div class="bannerArea">
			<div class="banner" :style="bg_img? 'background:url('+bg_img+') no-repeat;background-size:cover;':''"></div>
		</div>
		<Navigation v-loading="loading" :items="breadcrumbItems" :menus="menus" :checked="4" :bgColor="bgColor">
		</Navigation>
		<div class="content" style="min-height: 600px;">
			<div class="content_bg" style="min-height: 600px;">
			 
						<div class="news-list">
							<el-row :gutter="0" v-for="(item, index) in data" :key="index" class="news-item"
								:class="{ 'hover': hoverIndex === index }" @mouseover="hoverIndex = index"
								@mouseleave="hoverIndex = -1">
								<el-col :xs="5" :sm="3" :md="3" :lg="3">
									<div class="date">
										<div class="day">{{ formatDate(item.publishTime, 'DD') }}</div>
										<div class="month-year">{{item.publishTime?item.publishTime.substring(0,7):''}}
										</div>
									</div>
								</el-col>
								<el-col :xs="15" :sm="18" :md="18" :lg="18" class="newcontent">
									<div class="newcontentcontainer">
										<div class="title" @click="gotoInfo(item.id)">{{ item.titles }}</div>
										<p v-html="item.content" class="description"> </p>

									</div>
								</el-col>
								<el-col :xs="4" :sm="3" :md="3" :lg="3" class="newcontentMoreArea">
									<div class="moreInfoBtn" @click="gotoInfo(item.id)">{{$t("more")}} <i
											class="el-icon-d-arrow-right"></i></div>
								</el-col>
							</el-row>
							<el-row :gutter="24" type="flex" class="paginationArea">
							
								<el-pagination background :current-page.sync="currentPage" :page-size="pageSize"
									:layout="isShowJumper?'prev, pager, next,total,jumper ':'prev, next,total' " :total="total"
									:prev-text="$t('previousPage')" :next-text="$t('nextPage')"
									@current-change="handleCurrentChange" />
							</el-row>
						</div>
				 
				 
			</div>
		</div>
		<Footer></Footer>
	</div>
</template>

<script>
	import Header from '../../components/common/header/Header.vue'
	import Navigation from '../../components/common/navigation/Navigation.vue'
	import Footer from '../../components/common/footer/Footer.vue'
	import Pagination from '../../../src/components/common/Pagination.vue'
	import {
		productsAndServicesMenu
	} from '../../utils/menu.js'
	import {
		getStore,
		setStore
	} from '../../utils/tools.js';
	// 导入您需要的模块
	import Swiper from "swiper";
	export default {
		components: {
			Header,
			Navigation,
			Footer,
			Pagination
		},
		data() {
			return {
				isShowJumper: true,
				loading: true,
				data: [],
				pageSize: 10,
				total: 0,
				currentPage: 1,
				bg_img: '', //头部banner，默认值已绑定，有背景自动切换
				bgColor: "white", //white/red
				menus: productsAndServicesMenu,
				breadcrumbItems: [{
						label: this.$t('home'),
						to: '/'
					},
					{
						label: this.$t('productsAndServices'),
						to: '/productsAndServices'
					},
					{
						//销售公告
						label: this.$t('saleAnnouncements'),
						to: '/saleAnnouncements'
					}
				],
				hoverIndex: -1,
				companyProfile: {
					content: ""
				}

			};
		},
		computed: {},
		created() {
			this.bindSaleNoticePage()
		},
		mounted() {
			this.bindBg();
			if (this.$request.checkIsMobile()) {
				this.isShowJumper = false;
			}
		},
		methods: {
			/**
			 * 分页切换
			 */
			handleCurrentChange(currentPage) {
				this.currentPage = currentPage;
				setStore("saleAnnouncePage", this.currentPage);
				this.bindSaleNoticePage();
			},
			/**
			 * (1)	获取销售公告顶部背景
			 * http://127.0.0.1:9999/openApi/products/getSaleNoticeTopImage
			 */
			bindBg() {
				let params = {};
				let that = this;
				that.$request.getSaleNoticeTopImage(params).then(res => {
					this.bg_img = res.data.fileUrl
				}).catch((error) => {
					console.log(error);
				});

			},

			/**
			 * http://127.0.0.1:9999/openApi/products/getSaleNoticePage
			 */
			bindSaleNoticePage() {
				let saleAnnouncePage = parseInt(getStore("saleAnnouncePage"));
				this.currentPage = saleAnnouncePage > 0 ? saleAnnouncePage : this.currentPage;
				let params = {
					"pageNum": this.currentPage,
					"pageSize": this.pageSize
				};
				let that = this;
				that.$request.getSaleNoticePage(params).then(res => {
					this.data = res.data.records
					this.total = res.data.total;
					// this.currentPage = res.data.pageNum;
					this.loading = false;
				}).catch((error) => {
					console.log(error);
				});

			},
			formatDate(date, format) {
				const dateObj = new Date(date);
				const year = dateObj.getFullYear();
				const month = String(dateObj.getMonth() + 1).padStart(2, '0');
				const day = String(dateObj.getDate()).padStart(2, '0');

				// 根据传入的格式进行处理
				if (format === 'yyyy-MM') {
					return `${year}-${month}`;
				} else if (format === 'DD') {
					return day;
				}
				return date;
			},
			gotoNewList() {
				this.$router.push({
					name: "党建新闻列表"
				});
			},
			gotoInfo(id) {
				this.$router.push({
					name: this.$t('saleAnnouncementsInfo'),
					query: {
						id: id
					}
				});
			},

		}
	}
</script>

<style scoped>
	@import url("../../components/common/css/productsAndServices/productsAndServices.css");

	.saleAnnouncements .newArea {
		height: auto;
	}

	.saleAnnouncements .paginationArea {
		height: 70px;
		line-height: 70px;
		justify-content: center;
		padding-top: 20px;
	}

	/* 列表样式 */
	.saleAnnouncements .moreInfoBtn {
		width: 100%;

		align-items: center;
		text-align: center;
		color: #0484D7;
		font-size: 16px;
		padding: 0px;
	}

	/* 	.saleAnnouncements .moreInfoBtn:hover {
		background-color: #0396f0;
		color: #0396f0;
	} */


	.saleAnnouncements .news-list .news-item {
		height: 16vh;
		/* 	margin-bottom: 1vh ; */
		border-bottom: 1px solid #E8E6E5;
	}

	.saleAnnouncements .news-list .date {
		border-bottom: 2px solid #E8E6E5;

		background: #EDEDED;

		width: 80%;
	}

	.saleAnnouncements .news-list .title {
		font-size: 24px;
		font-weight: 530;
		color: #333333;
		height: 6vh;
		line-height: 6vh;
		padding: 0px;
		align-items: center;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.saleAnnouncements .news-list .number-of-views {
		font-size: 14px;
		font-weight: 400;
		color: #999999;
		height: 5vh;
		line-height: 5vh;
		align-items: center;
	}

	.saleAnnouncements .news-list .description {
		font-size: 14px;
		font-weight: 400;
		color: #666666;
		height: 60px;
		line-height: 30px;
		padding: 0px;
		align-items: center;
		overflow: hidden;
	}

	.saleAnnouncements .news-list .day {
		text-align: center;
		font-size: 2em;
		padding-top: 2vh;
		height: 7vh;
		font-weight: 400;
		color: #0484D7;
		/* padding-left: 15px; */
	}

	.saleAnnouncements .dateText {
		height: 4vh;
		line-height: 4vh;
		align-items: center;
		text-align: left;
		color: #777777;
		font-size: 1.2em;
		/* padding-left: 15px; */
		opacity: 0.8;
	}

	.saleAnnouncements .news-list .month-year {
		text-align: center;
		font-size: 1.2em;
		/* padding-left: 15px; */
		opacity: 0.8;
		color: #777777;
	}

	.saleAnnouncements .btn-next span {
		min-width: 50px !important;
	}

	.el-pagination span:not([class*=suffix]) {
		display: inline-block;
		font-size: 13px;
		min-width: 50px !important;
		height: 28px;
		line-height: 28px;
		vertical-align: top;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
	}

	.news-item {
		margin-bottom: 20px;
		cursor: pointer;
		overflow: hidden;
		transition: transform 0.3s ease;
		/* 添加过渡效果 */
	}

	.saleAnnouncements .news-item:hover {
		transform: scale(0.98)
	}

	.saleAnnouncements .news-item:hover .title {
		color: #0484D7;
	}

	.saleAnnouncements .news-item:hover .date {
		background-color: #0484D7;
	}

	.saleAnnouncements .news-item:hover .day,
	.saleAnnouncements .news-item:hover .month-year,
	.saleAnnouncements .news-item:hover .dateText {
		color: #FFF;
		opacity: 1;
	}

	.saleAnnouncements .news-list .newcontent {
		margin-top: 1vh;
	}

	.saleAnnouncements .news-list .newcontent .newcontentcontainer {
		display: flex;
		flex-direction: column;
		background-color: #FFF;
	}

	::v-deep .el-pagination span:not([class*=suffix]) {
		display: inline-block;
		font-size: 13px;
		min-width: 50px;
		height: 28px;
		line-height: 28px;
		vertical-align: top;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
	}

	.newcontentMoreArea {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}



	.content_bg {
		margin: 0px auto;
		padding: 50px;

	}

	@media (min-width: 2560px) {
		.content_bg {
			width: calc(2560px * 0.8);
		}

		.saleAnnouncements .news-list .date {
			height: calc(1px*(2560/1920*116));
		}

		.saleAnnouncements .newArea {
			height: calc(1px*(2560/1920*146));
		}

		.saleAnnouncements .news-list .news-item {
			height: calc(1px*(2560/1920*146));
			height: calc(1px*(2560/1920*146));

		}

		.saleAnnouncements .news-list .newcontent {
			height: calc(1px*(2560/1920*116));
		}

		.saleAnnouncements .news-list .newcontent .newcontentcontainer {
			height: 100%;
		}


		.saleAnnouncements .news-list .day {
			padding-top: 0px;
			height: calc(1px*(2560/1920*65));
			line-height: calc(1px*(2560/1920*65));
		}

		.saleAnnouncements .news-list .title {
			height: calc(1px*(2560/1920*51));
			line-height: calc(1px*(2560/1920*51));
		}

		.saleAnnouncements .news-list .description {
			height: calc(1px*(2560/1920*51));
			line-height: calc(1px*(2560/1920*51/2));
		}

		.newcontentMoreArea {
			height: calc(1px*(2560/1920*116));
		}
	}

	@media (max-width: 2560px) {
		.content_bg {
			width: calc(2560px * 0.8);
		}

		.saleAnnouncements .news-list .date {
			height: calc(1px*(2560/1920*116));
		}

		.saleAnnouncements .newArea {
			height: calc(1px*(2560/1920*146));
		}

		.saleAnnouncements .news-list .news-item {
			height: calc(1px*(2560/1920*146));
			height: calc(1px*(2560/1920*146));

		}

		.saleAnnouncements .news-list .newcontent {
			height: calc(1px*(2560/1920*116));
		}

		.saleAnnouncements .news-list .newcontent .newcontentcontainer {
			height: 100%;
		}


		.saleAnnouncements .news-list .day {
			padding-top: 0px;
			height: calc(1px*(2560/1920*65));
			line-height: calc(1px*(2560/1920*65));
		}

		.saleAnnouncements .news-list .title {
			height: calc(1px*(2560/1920*51));
			line-height: calc(1px*(2560/1920*51));
		}

		.saleAnnouncements .news-list .description {
			height: calc(1px*(2560/1920*51));
			line-height: calc(1px*(2560/1920*51/2));
		}

		.newcontentMoreArea {
			height: calc(1px*(2560/1920*116));
		}
	}

	@media (max-width: 2320px) {
		.content_bg {
			width: calc(2320px * 0.8);
		}

		.saleAnnouncements .news-list .date {
			height: calc(1px*(2320/1920*116));
		}

		.saleAnnouncements .newArea {
			height: calc(1px*(2320/1920*146));
		}

		.saleAnnouncements .news-list .news-item {
			height: calc(1px*(2320/1920*146));
			height: calc(1px*(2320/1920*146));

		}

		.saleAnnouncements .news-list .newcontent {
			height: calc(1px*(2320/1920*116));
		}

		.saleAnnouncements .news-list .newcontent .newcontentcontainer {
			height: 100%;
		}


		.saleAnnouncements .news-list .day {
			padding-top: 0px;
			height: calc(1px*(2320/1920*65));
			line-height: calc(1px*(2320/1920*65));
		}

		.saleAnnouncements .news-list .title {
			height: calc(1px*(2320/1920*51));
			line-height: calc(1px*(2320/1920*51));
		}

		.saleAnnouncements .news-list .description {
			height: calc(1px*(2320/1920*51));
			line-height: calc(1px*(2320/1920*51/2));
		}

		.newcontentMoreArea {
			height: calc(1px*(2320/1920*116));
		}
	}

	@media (max-width: 2120px) {
		.content_bg {
			width: calc(2120px * 0.8);
		}

		.saleAnnouncements .news-list .date {
			height: calc(1px*(2120/1920*116));
		}

		.saleAnnouncements .newArea {
			height: calc(1px*(2120/1920*146));
		}

		.saleAnnouncements .news-list .news-item {
			height: calc(1px*(2120/1920*146));
			height: calc(1px*(2120/1920*146));

		}

		.saleAnnouncements .news-list .newcontent {
			height: calc(1px*(2120/1920*116));
		}

		.saleAnnouncements .news-list .newcontent .newcontentcontainer {
			height: 100%;
		}


		.saleAnnouncements .news-list .day {
			padding-top: 0px;
			height: calc(1px*(2120/1920*65));
			line-height: calc(1px*(2120/1920*65));
		}

		.saleAnnouncements .news-list .title {
			height: calc(1px*(2120/1920*51));
			line-height: calc(1px*(2120/1920*51));
		}

		.newcontentMoreArea {
			height: calc(1px*(2120/1920*116));
		}

		.saleAnnouncements .news-list .description {
			height: calc(1px*(2120/1920*51));
			line-height: calc(1px*(2120/1920*51/2));
		}
	}

	@media (max-width: 1920px) {
		.content_bg {
			width: calc(1920px * 0.8);
		}

		.saleAnnouncements .news-list .date {
			height: 116px;
		}

		.saleAnnouncements .news-list .day {
			padding-top: 0px;
			height: 65px;
			line-height: 65px;
		}

		.saleAnnouncements .news-list .title {
			height: 51px;
			line-height: 51px;
		}

		.saleAnnouncements .news-list .description {
			height: 51px;
			line-height: calc(51px/2);
		}

		.saleAnnouncements .newArea {
			height: 146px;
		}

		.saleAnnouncements .news-list .news-item {
			height: 146px;
		}

		.saleAnnouncements .news-list .newcontent {
			height: 116px;
		}

		.saleAnnouncements .news-list .newcontent .newcontentcontainer {
			height: 100%;
		}

		.newcontentMoreArea {
			height: 116px;
		}

	}

	@media (max-width: 1720px) {


		.content_bg {
			width: calc(1720px * 0.8);
		}

		.saleAnnouncements .news-list .date {
			height: calc(1px*(1720/1920*116));
		}

		.newcontentMoreArea {
			height: calc(1px*(1720/1920*116));
		}

		.saleAnnouncements .newArea {
			height: calc(1px*(1720/1920*146));
		}

		.saleAnnouncements .news-list .news-item {
			height: calc(1px*(1720/1920*146));
			height: calc(1px*(1720/1920*146));

		}

		.saleAnnouncements .news-list .newcontent {
			height: calc(1px*(1720/1920*116));
		}

		.saleAnnouncements .news-list .newcontent .newcontentcontainer {
			height: 100%;
		}

		.saleAnnouncements .moreInfoBtn {
			height: calc(1px*(1720/1920*116));
			line-height: calc(1px*(1720/1920*116));
		}

		.saleAnnouncements .news-list .day {
			padding-top: 0px;
			height: calc(1px*(1720/1920*65));
			line-height: calc(1px*(1720/1920*65));
		}

		.saleAnnouncements .news-list .title {
			height: calc(1px*(1720/1920*51));
			line-height: calc(1px*(1720/1920*51));
		}

		.saleAnnouncements .news-list .description {
			height: calc(1px*(1720/1920*51));
			line-height: calc(1px*(1720/1920*51/2));
		}
	}

	@media (max-width: 1520px) {
		.content_bg {
			width: calc(1520px * 0.8);
		}

		.saleAnnouncements .news-list .date {
			height: calc(1px*(1520/1920*116));
		}

		.newcontentMoreArea {
			height: calc(1px*(1520/1920*116));
		}

		.saleAnnouncements .newArea {
			height: calc(1px*(1520/1920*146));
		}

		.saleAnnouncements .news-list .news-item {
			height: calc(1px*(1520/1920*146));
			height: calc(1px*(1520/1920*146));

		}

		.saleAnnouncements .news-list .newcontent {
			height: calc(1px*(1520/1920*116));
		}

		.saleAnnouncements .news-list .newcontent .newcontentcontainer {
			height: 100%;
		}


		.saleAnnouncements .news-list .day {
			padding-top: 0px;
			height: calc(1px*(1520/1920*65));
			line-height: calc(1px*(1520/1920*65));
		}

		.saleAnnouncements .news-list .title {
			height: calc(1px*(1520/1920*51));
			line-height: calc(1px*(1520/1920*51));
		}

		.saleAnnouncements .news-list .description {
			height: calc(1px*(1520/1920*51));
			line-height: calc(1px*(1520/1920*51/2));
		}
	}

	@media (max-width: 1366px) {
		.content_bg {
			width: calc(1366px * 0.8);
		}

		.saleAnnouncements .news-list .date {
			height: calc(1px*(1366/1920*116));
		}

		.saleAnnouncements .newArea {
			height: calc(1px*(1366/1920*146));
		}

		.newcontentMoreArea {
			height: calc(1px*(1366/1920*116));
		}

		.saleAnnouncements .news-list .news-item {
			height: calc(1px*(1366/1920*146));
			height: calc(1px*(1366/1920*146));

		}

		.saleAnnouncements .news-list .newcontent {
			height: calc(1px*(1366/1920*116));
		}

		.saleAnnouncements .news-list .newcontent .newcontentcontainer {
			height: 100%;
		}


		.saleAnnouncements .news-list .day {
			padding-top: 0px;
			height: calc(1px*(1366/1920*65));
			line-height: calc(1px*(1366/1920*65));
		}

		.saleAnnouncements .news-list .title {
			height: calc(1px*(1366/1920*51));
			line-height: calc(1px*(1366/1920*51));
		}

		.saleAnnouncements .news-list .description {
			height: calc(1px*(1366/1920*51));
			line-height: calc(1px*(1366/1920*51/2));
		}
	}

	@media (max-width: 1120px) {
		.content_bg {
			width: 100%
		}
	}

	@media (max-width: 1024px) {}

	@media (max-width: 900px) {
		.saleAnnouncements .news-list .description {
			/* height: calc(1px*(900/1920*51));
			line-height: calc(1px*(900/1920*51/2)); */
			height: 60px;
			line-height: 30px;
		}
	}

	@media (max-width:768px) {
		.saleAnnouncements .news-list .newcontent {
			padding: 0px 5px;
			margin-top: 1vh;
		}

		.saleAnnouncements .news-list .title {
			font-size: 1rem;
			padding: 0px;
			height: 30px;
		}

		.saleAnnouncements .news-list .description {
			font-size: 12px;
			height: 50px;
			line-height: 26px;
		}

		.saleAnnouncements .moreInfoBtn {
			font-size: 12px;
		}

		.saleAnnouncements .news-list .day {
			font-size: 30px;
			padding-top: 5px;
			height: 50px;
			color: #fff;
		}

		.saleAnnouncements .news-list .month-year {
			font-size: 12px;
			color: #fff;
			opacity: 1;
		}

		@media (max-width:440px) {

			.saleAnnouncements .news-list .date {
				width: 100%;
				background-color: #0484D7;
			}

			.saleAnnouncements .moreInfoBtn {
				font-size: 8px !important;
			}

			.saleAnnouncements .news-list .title {
				font-size: 16px;
				color: #0484D7;
				padding: 0px;
				height: 30px;
				line-height: 30px;
			}

			.saleAnnouncements .news-list .description {
				font-size: 12px;
				height: 40px;
				line-height: 22px !important;
			}
		}

	}
</style>